package com.member.shop.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import cn.hutool.core.collection.CollectionUtil;
import com.member.common.utils.DateUtils;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.shop.domain.SysBizGoodsSku;
import com.member.shop.domain.SysBizRecommendGoods;
import com.member.shop.mapper.SysBizRecommendGoodsMapper;
import org.springframework.stereotype.Service;
import com.member.shop.mapper.SysBizRecommendCategoryMapper;
import com.member.shop.domain.SysBizRecommendCategory;
import com.member.shop.service.ISysBizRecommendCategoryService;

/**
 * 推荐分类Service业务层处理
 *
 * @author lixinchen
 * @date 2025-01-08
 */
@Service
public class SysBizRecommendCategoryServiceImpl extends ServiceImpl<SysBizRecommendCategoryMapper, SysBizRecommendCategory> implements ISysBizRecommendCategoryService {
    @Resource
    private SysBizRecommendCategoryMapper sysBizRecommendCategoryMapper;

    @Resource
    private SysBizRecommendGoodsMapper sysBizRecommendGoodsMapper;

    /**
     * 查询推荐分类
     *
     * @param id 推荐分类主键
     * @return 推荐分类
     */
    @Override
    public SysBizRecommendCategory selectSysBizRecommendCategoryById(Long id) {
        return sysBizRecommendCategoryMapper.selectById(id);
    }

    /**
     * 查询推荐分类列表
     *
     * @param queryWrapper 推荐分类
     * @return 推荐分类
     */
    @Override
    public List<SysBizRecommendCategory> selectSysBizRecommendCategoryList(LambdaQueryWrapper<SysBizRecommendCategory> queryWrapper) {
        return sysBizRecommendCategoryMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysBizRecommendCategory> selectSysBizRecommendCategoryList(SysBizRecommendCategory sysBizRecommendCategory) {
        return sysBizRecommendCategoryMapper.selectSysBizRecommendCategoryList(sysBizRecommendCategory);
    }

    /**
     * 新增推荐分类
     *
     * @param sysBizRecommendCategory 推荐分类
     * @return 结果
     */
    @Override
    public int insertSysBizRecommendCategory(SysBizRecommendCategory sysBizRecommendCategory) {
        sysBizRecommendCategory.setCreateTime(DateUtils.getNowDate());
        return sysBizRecommendCategoryMapper.insert(sysBizRecommendCategory);
    }

    /**
     * 修改推荐分类
     *
     * @param sysBizRecommendCategory 推荐分类
     * @return 结果
     */
    @Override
    public int updateSysBizRecommendCategory(SysBizRecommendCategory sysBizRecommendCategory) {
        sysBizRecommendCategory.setUpdateTime(DateUtils.getNowDate());
        return sysBizRecommendCategoryMapper.updateById(sysBizRecommendCategory);
    }

    /**
     * 批量删除推荐分类
     *
     * @param ids 需要删除的推荐分类主键
     * @return 结果
     */
    @Override
    public int deleteSysBizRecommendCategoryByIds(Long[] ids) {
        return sysBizRecommendCategoryMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除推荐分类信息
     *
     * @param id 推荐分类主键
     * @return 结果
     */
    @Override
    public int deleteSysBizRecommendCategoryById(Long id) {
        return sysBizRecommendCategoryMapper.deleteById(id);
    }

    @Override
    public List<SysBizGoodsSku> listGoodsBind(Long id) {
        return sysBizRecommendCategoryMapper.listGoodsBind(id);
    }
}
